/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.Wires.impl;

import EA_Model.IEC61970.Core.impl.PowerSystemResourceImpl;

import EA_Model.IEC61970.Wires.RegulatingControl;
import EA_Model.IEC61970.Wires.RegulatingControlModeKind;
import EA_Model.IEC61970.Wires.WiresPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Regulating Control</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.RegulatingControlImpl#getDiscrete <em>Discrete</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.RegulatingControlImpl#getMode <em>Mode</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.RegulatingControlImpl#getTargetRange <em>Target Range</em>}</li>
 *   <li>{@link EA_Model.IEC61970.Wires.impl.RegulatingControlImpl#getTargetValue <em>Target Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RegulatingControlImpl extends PowerSystemResourceImpl implements RegulatingControl {
	/**
	 * The cached value of the '{@link #getDiscrete() <em>Discrete</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDiscrete()
	 * @generated
	 * @ordered
	 */
	protected EA_Model.IEC61970.Domain.Boolean discrete;

	/**
	 * The default value of the '{@link #getMode() <em>Mode</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMode()
	 * @generated
	 * @ordered
	 */
	protected static final RegulatingControlModeKind MODE_EDEFAULT = RegulatingControlModeKind.VOLTAGE;

	/**
	 * The cached value of the '{@link #getMode() <em>Mode</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMode()
	 * @generated
	 * @ordered
	 */
	protected RegulatingControlModeKind mode = MODE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getTargetRange() <em>Target Range</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTargetRange()
	 * @generated
	 * @ordered
	 */
	protected EA_Model.IEC61970.Domain.Float targetRange;

	/**
	 * The cached value of the '{@link #getTargetValue() <em>Target Value</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTargetValue()
	 * @generated
	 * @ordered
	 */
	protected EA_Model.IEC61970.Domain.Float targetValue;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RegulatingControlImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WiresPackage.Literals.REGULATING_CONTROL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EA_Model.IEC61970.Domain.Boolean getDiscrete() {
		if (discrete != null && discrete.eIsProxy()) {
			InternalEObject oldDiscrete = (InternalEObject)discrete;
			discrete = (EA_Model.IEC61970.Domain.Boolean)eResolveProxy(oldDiscrete);
			if (discrete != oldDiscrete) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.REGULATING_CONTROL__DISCRETE, oldDiscrete, discrete));
			}
		}
		return discrete;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EA_Model.IEC61970.Domain.Boolean basicGetDiscrete() {
		return discrete;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDiscrete(EA_Model.IEC61970.Domain.Boolean newDiscrete) {
		EA_Model.IEC61970.Domain.Boolean oldDiscrete = discrete;
		discrete = newDiscrete;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.REGULATING_CONTROL__DISCRETE, oldDiscrete, discrete));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RegulatingControlModeKind getMode() {
		return mode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMode(RegulatingControlModeKind newMode) {
		RegulatingControlModeKind oldMode = mode;
		mode = newMode == null ? MODE_EDEFAULT : newMode;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.REGULATING_CONTROL__MODE, oldMode, mode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EA_Model.IEC61970.Domain.Float getTargetRange() {
		if (targetRange != null && targetRange.eIsProxy()) {
			InternalEObject oldTargetRange = (InternalEObject)targetRange;
			targetRange = (EA_Model.IEC61970.Domain.Float)eResolveProxy(oldTargetRange);
			if (targetRange != oldTargetRange) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.REGULATING_CONTROL__TARGET_RANGE, oldTargetRange, targetRange));
			}
		}
		return targetRange;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EA_Model.IEC61970.Domain.Float basicGetTargetRange() {
		return targetRange;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTargetRange(EA_Model.IEC61970.Domain.Float newTargetRange) {
		EA_Model.IEC61970.Domain.Float oldTargetRange = targetRange;
		targetRange = newTargetRange;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.REGULATING_CONTROL__TARGET_RANGE, oldTargetRange, targetRange));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EA_Model.IEC61970.Domain.Float getTargetValue() {
		if (targetValue != null && targetValue.eIsProxy()) {
			InternalEObject oldTargetValue = (InternalEObject)targetValue;
			targetValue = (EA_Model.IEC61970.Domain.Float)eResolveProxy(oldTargetValue);
			if (targetValue != oldTargetValue) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WiresPackage.REGULATING_CONTROL__TARGET_VALUE, oldTargetValue, targetValue));
			}
		}
		return targetValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EA_Model.IEC61970.Domain.Float basicGetTargetValue() {
		return targetValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTargetValue(EA_Model.IEC61970.Domain.Float newTargetValue) {
		EA_Model.IEC61970.Domain.Float oldTargetValue = targetValue;
		targetValue = newTargetValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WiresPackage.REGULATING_CONTROL__TARGET_VALUE, oldTargetValue, targetValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WiresPackage.REGULATING_CONTROL__DISCRETE:
				if (resolve) return getDiscrete();
				return basicGetDiscrete();
			case WiresPackage.REGULATING_CONTROL__MODE:
				return getMode();
			case WiresPackage.REGULATING_CONTROL__TARGET_RANGE:
				if (resolve) return getTargetRange();
				return basicGetTargetRange();
			case WiresPackage.REGULATING_CONTROL__TARGET_VALUE:
				if (resolve) return getTargetValue();
				return basicGetTargetValue();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WiresPackage.REGULATING_CONTROL__DISCRETE:
				setDiscrete((EA_Model.IEC61970.Domain.Boolean)newValue);
				return;
			case WiresPackage.REGULATING_CONTROL__MODE:
				setMode((RegulatingControlModeKind)newValue);
				return;
			case WiresPackage.REGULATING_CONTROL__TARGET_RANGE:
				setTargetRange((EA_Model.IEC61970.Domain.Float)newValue);
				return;
			case WiresPackage.REGULATING_CONTROL__TARGET_VALUE:
				setTargetValue((EA_Model.IEC61970.Domain.Float)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WiresPackage.REGULATING_CONTROL__DISCRETE:
				setDiscrete((EA_Model.IEC61970.Domain.Boolean)null);
				return;
			case WiresPackage.REGULATING_CONTROL__MODE:
				setMode(MODE_EDEFAULT);
				return;
			case WiresPackage.REGULATING_CONTROL__TARGET_RANGE:
				setTargetRange((EA_Model.IEC61970.Domain.Float)null);
				return;
			case WiresPackage.REGULATING_CONTROL__TARGET_VALUE:
				setTargetValue((EA_Model.IEC61970.Domain.Float)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WiresPackage.REGULATING_CONTROL__DISCRETE:
				return discrete != null;
			case WiresPackage.REGULATING_CONTROL__MODE:
				return mode != MODE_EDEFAULT;
			case WiresPackage.REGULATING_CONTROL__TARGET_RANGE:
				return targetRange != null;
			case WiresPackage.REGULATING_CONTROL__TARGET_VALUE:
				return targetValue != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (mode: ");
		result.append(mode);
		result.append(')');
		return result.toString();
	}

} //RegulatingControlImpl
